<template>
	<div>
		<el-button type="primary" @click="submitClick"> 保 存 </el-button>

		<el-form :model="curData" ref="curRef" style="margin-top: 20px;">
			<el-form-item label="" prop="content">
				<gz-editor rootPath="sys/config" :height="maxHeight" v-model="curData.content"></gz-editor>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	export default {
		components: {},
		name: 'YwConfigFuwenben',
		props: {
			type: {
				default: "",
				type: String
			}
		},
		data() {
			return {
				curData: {
					content: null
				},
				maxHeight:document.body.clientHeight - 175
			}
		},
		watch: {
			type(newVal, oldVal) {
				this.type = newVal
				this.initData(this.type)
			}
		},
		mounted() {
			this.initData(this.type)
			// this.maxHeight = document.body.clientHeight - 280
		},
		methods: {
			initData(type) {
				this.$api.appConfigFindByType(type).then(result => {
					this.curData = JSON.parse(result.value)
				})
			},
			submitClick() {
				this.$refs.curRef.validate((valid) => {
					if (valid) {
						this.$api.appConfigEdit({
							type: this.type,
							value: JSON.stringify(this.curData)
						});
					}
				});
			},
		}
	}
</script>

<style>

</style>
